package org.example;

public class    Result<T> {
    private static final int SUCCESS = 200;
    private static final int FAULED = 500;
    private  int code = SUCCESS;    
    private  String message="success";
    private T data;
    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Result() {
    }

    public Result(int code, String message, T data) {
        this.data = data;
        this.message = message;
        this.code = code;
    }

    public static <T> Result<T> ok() {
        return new Result(SUCCESS,"success",null);
    }

    public static <T> Result<T> ok(int code,String message) {
        return new Result(code,message,null);
    }

    public static <T> Result<T> ok(T data) {
        return new Result(SUCCESS,"success",data);
    }

    public static <T> Result<T> error() {
        return new Result(FAULED,"error",null);
    }
    public static <T> Result<T> error(int code,String message) {
        return new Result(code,message,null);
    }
    public static <T> Result<T> error(String message) {
        return new Result(FAULED,message,null);
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
